<template>
  <div class="list-table">
    <div class="area-header">
      <span class="area-header-title">{{ $t('退出决策') }}</span>
    </div>
    <el-form ref="queryForm" :model="queryParams" :inline="true">
      <el-form-item :label="$t('项目名称')" prop="dealName">
        <el-input v-model="queryParams.dealName" :placeholder="$t('项目名称')" size="small" @keyup.enter.native="queryHandle" />
      </el-form-item>
      <!--      <el-form-item :label="$t('行业')" prop="dealIndustry">
        <dictSelect
          v-model="queryParams.dealIndustry"
          :clearable="true"
          dictionary="deal_industry"
        />
      </el-form-item>
      <el-form-item :label="$t('投资主体')" prop="investmentNames">
        <el-input v-model="queryParams.investmentNames" :placeholder="$t('投资主体')" size="small" @keyup.enter.native="queryHandle" />
      </el-form-item>-->
      <el-form-item :label="$t('负责人')" prop="teamNames">
        <el-input v-model="queryParams.teamNames" :placeholder="$t('负责人')" size="small" @keyup.enter.native="queryHandle" />
      </el-form-item>
      <el-form-item :label="$t('退出方式')" prop="exitWay">
        <dictSelect
          v-model="queryParams.exitWay"
          :clearable="true"
          dictionary="exit_plan_item"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t("搜索") }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t("重置") }}</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" tooltip-effect="darkTable" :data="exitWayList" border>
      <el-table-column :label="$t('序号')" type="index" align="center" show-overflow-tooltip width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('项目名称')" align="center" prop="dealName" :show-overflow-tooltip="true" min-width="150px" />
      <el-table-column :label="$t('行业')" align="center" prop="dealIndustry" :formatter="industryFormat" show-overflow-tooltip min-width="130" />
      <el-table-column :label="$t('投资主体')" align="center" prop="investmentNames" show-overflow-tooltip min-width="180" />
      <el-table-column :label="$t('负责人')" align="center" prop="teamNames" show-overflow-tooltip min-width="180" />
      <el-table-column :label="$t('出售排序')" align="center" prop="sellSort" show-overflow-tooltip min-width="120" />
      <el-table-column :label="$t('退出方式')" align="center" prop="exitWay" :formatter="exitWayFormat" show-overflow-tooltip min-width="120" />

      <el-table-column v-if="queryParams.exitWay === 'KGQCS' && extend" :label="$t('主要股东及比例')" align="center" prop="mainHolderRatioKgq" show-overflow-tooltip min-width="130" />
      <el-table-column v-if="queryParams.exitWay === 'KGQCS' && extend" :label="$t('预计出售估值')" align="center" prop="expectSellKgq" show-overflow-tooltip min-width="130" />
      <el-table-column v-if="queryParams.exitWay === 'KGQCS' && extend" :label="$t('是否有拖售权')" align="center" prop="dragAlongRightsKgq" show-overflow-tooltip min-width="130" />
      <el-table-column v-if="queryParams.exitWay === 'KGQCS' && extend" :label="$t('潜在买家范围')" align="center" prop="potentialBuyerKgq" show-overflow-tooltip min-width="130" />
      <el-table-column v-if="queryParams.exitWay === 'KGQCS' && extend" :label="$t('下一步计划')" align="center" prop="nextPlanKgq" show-overflow-tooltip min-width="180" />

      <el-table-column v-if="queryParams.exitWay === 'SSGQCS' && extend" :label="$t('拟出售比例')" align="center" prop="sellRatioSsgq" :formatter="sellRatioFormat" show-overflow-tooltip min-width="130" />
      <el-table-column v-if="queryParams.exitWay === 'SSGQCS' && extend" :label="$t('出售时机')" align="center" prop="sellOpportunitySsgq" show-overflow-tooltip min-width="130" />
      <el-table-column v-if="queryParams.exitWay === 'SSGQCS' && extend" :label="$t('预计出售估值')" align="center" prop="expectSellSsgq" show-overflow-tooltip min-width="130" />
      <el-table-column v-if="queryParams.exitWay === 'SSGQCS' && extend" :label="$t('潜在买家范围')" align="center" prop="potentialBuyerSsgq" show-overflow-tooltip min-width="130" />
      <el-table-column v-if="queryParams.exitWay === 'SSGQCS' && extend" :label="$t('下一步计划')" align="center" prop="nextPlanSsgq" show-overflow-tooltip min-width="180" />

      <el-table-column v-if="queryParams.exitWay === 'HGJQS' && extend" :label="$t('何时触发回购')" align="center" prop="triggerRepurchaseHg" show-overflow-tooltip min-width="130">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.triggerRepurchaseHg) }}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="queryParams.exitWay === 'HGJQS' && extend" :label="$t('预计回收金额')+ $t('金额单位')" align="center" prop="expectRecoverMoneyHg" show-overflow-tooltip min-width="130">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.expectRecoverMoneyHg, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="queryParams.exitWay === 'HGJQS' && extend" :label="$t('下一步计划')" align="center" prop="nextPlanHg" show-overflow-tooltip min-width="180" />

      <el-table-column v-if="queryParams.exitWay === 'IPO' && extend" :label="$t('预计上市地')" align="center" prop="expectListedAddressIpo" show-overflow-tooltip min-width="130" />
      <el-table-column v-if="queryParams.exitWay === 'IPO' && extend" :label="$t('申报/上市时间')" align="center" prop="listedTimeIpo" show-overflow-tooltip min-width="130">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.listedTimeIpo) }}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="queryParams.exitWay === 'IPO' && extend" :label="$t('上市后锁定期')" align="center" prop="listedLockPeriodIpo" show-overflow-tooltip min-width="130" />
      <el-table-column v-if="queryParams.exitWay === 'IPO' && extend" :label="$t('需关注事项')" align="center" prop="focusItemIpo" show-overflow-tooltip min-width="130" />
      <el-table-column v-if="queryParams.exitWay === 'IPO' && extend" :label="$t('下一步计划')" align="center" prop="nextPlanIpo" show-overflow-tooltip min-width="180" />

      <el-table-column v-if="queryParams.exitWay === 'CYGC' && extend" :label="$t('继续持有原因')" align="center" prop="reasonHoldingGc" show-overflow-tooltip min-width="130" />
      <el-table-column v-if="queryParams.exitWay === 'CYGC' && extend" :label="$t('关注事项')" align="center" prop="focusItemGc" show-overflow-tooltip min-width="130" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { exitWayReport } from '@/api/sass/kaihui/exit/kaiHuiDealExit'

export default {
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 退出申请表格数据
      exitWayList: [],
      // 退出方式字典
      exitWayOptions: [],
      // 项目行业
      industryOptions: [],
      // 出售比例字典
      sellRatioOptions: [],
      // 是否展示扩展字段
      extend: false,
      // 查询参数
      queryParams: {
        dealName: undefined,
        // investmentNames: undefined,
        teamNames: undefined,
        exitWay: undefined,
        pageNum: 1,
        pageSize: 10
      }
    }
  },
  created() {
    this.getList()
    this.getDicts('exit_plan_item').then(response => {
      this.exitWayOptions = response.data
    })
    this.getDicts('deal_industry').then(response => {
      this.industryOptions = response.data
    })
    this.getDicts('sell_ratio_ssgq').then(response => {
      this.sellRatioOptions = response.data
    })
  },
  methods: {
    /** 查询退出申请列表 */
    getList() {
      if (this.queryParams.exitWay === '' || this.queryParams.exitWay === undefined) {
        this.msgInfo('请先选择退出方式！')
        this.loading = false
        return
      }
      this.loading = true
      this.extend = true
      exitWayReport(this.queryParams).then(response => {
        this.exitWayList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 退出方式字典翻译
    // eslint-disable-next-line no-unused-vars
    exitWayFormat(row) {
      return this.selectDictLabel(this.exitWayOptions, row.exitWay)
    },
    industryFormat(row) {
      return this.selectDictLabel(this.industryOptions, row.dealIndustry)
    },
    sellRatioFormat(row) {
      return this.selectDictLabel(this.sellRatioOptions, row.sellRatioSsgq)
    },
    /** 搜索按钮操作 */
    queryHandle() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.extend = false
      this.exitWayList = []
      this.queryHandle()
    }
  }
}
</script>
